package com.xs.designpattern;

import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
 * @author xs
 */
@RequiredArgsConstructor
public abstract class Unit {
    private final Unit[] children;

    /**
     * 接待访客
     */
    public void accept(UnitVisitor visitor) {
        Arrays.stream(children).forEach(child -> child.accept(visitor));
    }
}
